/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package logica;

import javax.swing.JFrame;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;

import org.jfree.ui.RefineryUtilities;

/**
 * This demonstration shows a 3D bar chart with item labels displayed.
 *
 */
public class puesto extends JFrame {

    /**
     * Creates a new demo.
     *
     * @param title  the frame title.
     *
     *
     */



    private static double ganancia=0.0;
    private static String nombre="";


    public puesto(double gana, String nom){

        nombre = nom;
        ganancia = gana;

        final CategoryDataset dataset = createDataset();
        final JFreeChart chart = createChart(dataset);
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);

    }


   private static CategoryDataset createDataset() {

        final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(ganancia, "", nombre);


        return dataset;

    }

   public static JPanel crearpanel(){
        JFreeChart chart = createChart(createDataset());
       return new ChartPanel(chart);
   }

    private static JFreeChart createChart(CategoryDataset dataset) {

        final JFreeChart chart = ChartFactory.createBarChart3D(
            "Ganancias",      // chart title
            "",               // domain axis label
            "Euros",                  // range axis label
            dataset,                  // data
            PlotOrientation.VERTICAL, // orientation
            false,                     // include legend
            true,                     // tooltips
            false                     // urls
        );

        final CategoryPlot plot = chart.getCategoryPlot();
        final CategoryAxis axis = plot.getDomainAxis();


        final CategoryItemRenderer renderer = plot.getRenderer();
        renderer.setItemLabelsVisible(true);
        final BarRenderer r = (BarRenderer) renderer;
        r.setMaximumBarWidth(0.3);

        return chart;

    }


    /**
     * Starting point for the demonstration application.
     *
     * @param args  ignored.
     */
    public static void main(final String[] args) {

        final puesto demo = new puesto(100.0, "josuedani");
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);

    }


}
